import numpy as np
import matplotlib.pyplot as plt

M = np.load('map_data.npy')
path_data = np.load('path_L1_L2.npy', allow_pickle=True)
plt.rcParams['font.family'] = 'Times New Roman'
plt.rcParams['font.size'] = 12
plt.rcParams['axes.labelweight'] = 'bold'  # 标签加粗
plt.rcParams['axes.titleweight'] = 'bold'  # 标题加粗
plt.rcParams['axes.titlepad'] = 10  # 标题与图表的距离
plt.rcParams['xtick.labelsize'] = 10  # x轴标签大小
plt.rcParams['ytick.labelsize'] = 10  # y轴标签大小

# 绘制M[0]的热力图
plt.figure(figsize=(10, 8))
target = M[:, :, 0] - M[:, :, 3] * 10000
color_segments = [
    (0.0, (0.2, 0.3, 1.0)),   # 深蓝，对应低值
    (0.2, (0.2, 0.8, 1.0)),   # 浅蓝
    (0.4, (0.2, 1.0, 0.8)),   # 蓝绿
    (0.6, (0.8, 1.0, 0.2)),   # 绿黄
    (0.8, (1.0, 0.8, 0.2)),   # 黄棕
    (1.0, (1.0, 0.3, 0.2))    # 浅棕，对应高值
]

from matplotlib.colors import LinearSegmentedColormap
cmap = LinearSegmentedColormap.from_list('custom_cmap', color_segments)
plt.imshow(target.T, cmap=cmap, interpolation='nearest', vmin=4500, vmax=6000)
plt.colorbar(label='Value')
plt.title('Map')
plt.xlabel('X Coordinate')
plt.ylabel('Y Coordinate')
plt.gca().invert_yaxis()

# 定义点的数据
points = [
    (10996, 6648), (9979, 5931), (9564, 4823), (8570, 4707), (8154, 3875),
    (7739, 3390), (6907, 2189), (6560, 1173), (7054, 410), (5333, 8223),
    (8039, 7941), (5075, 6987), (4698, 6162), (3279, 5169), (5922, 4615),
    (4305, 3413), (3265, 2674), (4166, 780), (3150, 10713)
]
path = np.load('path_L1_L2.npy', allow_pickle=True)
x_coords, y_coords = zip(*path)
plt.plot(x_coords, y_coords, 'r-', linewidth=2)
for x, y in points:
    plt.scatter(x, y, color="#df12ce" , zorder=5)
x_coords, y_coords = zip(*path_data)
plt.plot(y_coords, x_coords, 'b-', linewidth=2)
plt.show()